<?php

namespace app\admin\model;

use think\Model;


class System extends Model
{

    

    

    // 表名
    protected $name = 'system';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'level_text',
        'flag_text',
    ];
    

    
    public function getLevelList()
    {
        return ['1' => __('系统'), '2' => __('版本'), '3' => __('系统版本'), '4' => __('发布时间'), '5' => __('位数')];
    }


    public function getLevelTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['level']) ? $data['level'] : '');
        $list = $this->getLevelList();
        return isset($list[$value]) ? $list[$value] : '';
    }



    public function getFlagList()
    {
        return ['new' => __('New'), 'welcome' => __('Welcome'), 'classic' => __('Classic'), 'legend' => __('Legend')];
    }

    public function getFlagTextAttr($value, $data)
    {
        $value = $value ? $value : $data['flag'];
        $valueArr = explode(',', $value);
        $list = $this->getFlagList();
        return implode(',', array_intersect_key($list, array_flip($valueArr)));
    }
}
